package com.kevineric.pokedex;

import android.app.Activity;
import android.app.SearchManager;
import android.content.Intent;
import android.os.Bundle;
import android.view.View.*;
import android.view.*;
import android.widget.*;

import java.io.PrintStream;
import java.net.URL;
import java.util.Scanner;


public class Pokedex extends Activity {
	private PokedexDbAdapter mDb;
	
    private OnClickListener myListener= new OnClickListener() {
        public void onClick(View v) {
        	TextView label = (TextView)findViewById(R.id.label);
      
        	EditText entry= (EditText)findViewById(R.id.entry);
          	label.setText(entry.getText());
          	try{
          		Scanner sc=new Scanner(new URL("http://www.google.com").openStream());
          		label.setText(sc.nextLine());
          		
          	}catch(Exception e){
          		label.setText(e.toString());
          		e.printStackTrace();
          	}
          }
    };
	
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        
        Button button = (Button)findViewById(R.id.ok);
        // Register the onClick listener with the implementation above
        button.setOnClickListener(myListener);
        
        System.setErr(new PrintStream(new LogTool("System.err")));
        System.setOut(new PrintStream(new LogTool("System.out")));
        
        System.out.println("Pokedex started");
        
        //initialize database
        
        mDb=new PokedexDbAdapter(this);
        mDb.open();
    }
    
    public boolean onCreateOptionsMenu(Menu menu) {
        MenuInflater inflater = getMenuInflater();
        inflater.inflate(R.menu.main_menu, menu);
        
        return true;
    }

}